package com.tanhua.server.controller;

import com.tanhua.model.vo.PageResult;
import com.tanhua.model.vo.VideoVo;
import com.tanhua.server.service.VideoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("smallVideos")
public class VideoController {

    @Autowired
    private VideoService videoService;

    /**
     * 发布小视频
     * @param videoThumbnail
     * @param videoFile
     * @return
     */
    @PostMapping
    public ResponseEntity publish(MultipartFile videoThumbnail, MultipartFile videoFile){
        videoService.publish(videoThumbnail, videoFile);
        return ResponseEntity.ok(null);
    }

    /**
     * 小视频列表
     * @param page
     * @param pagesize
     * @return
     */
    @GetMapping
    public ResponseEntity videoList(Long page, Long pagesize){
        PageResult<VideoVo> pageResult = videoService.findPage(page,pagesize);
        return ResponseEntity.ok(pageResult);
    }
}
